package com.insta.android.model;

import android.os.Parcel;
import android.os.Parcelable;

public class Music implements Parcelable {
	
	private int _id;
	private String _titre;
	private int _duree;
	private String _artiste;
	private String _album;
	private String _filename;
	private int _rating;
	
	
	public Music() {}
	public Music(int _id, String _titre, int _duree, String _artiste, String _filename) {
		super();
		this._id = _id;
		this._titre = _titre;
		this._duree = _duree;
		this._artiste = _artiste;
		this._filename = _filename;
	}
	
	public int get_id() {
		return _id;
	}
	public void set_id(int _id) {
		this._id = _id;
	}
	public String get_titre() {
		return _titre;
	}
	public void set_titre(String _titre) {
		this._titre = _titre;
	}
	public int get_duree() {
		return _duree;
	}
	public void set_duree(int _duree) {
		this._duree = _duree;
	}
	public String get_artiste() {
		return _artiste;
	}
	public void set_artiste(String _artiste) {
		this._artiste = _artiste;
	}
	public String get_album() {
		return _album;
	}
	public void set_album(String _album) {
		this._album = _album;
	}
	public String get_filename() {
		return _filename;
	}
	public void set_filename(String _filename) {
		this._filename = _filename;
	}
	public int get_rating() {
		return _rating;
	}
	public void set_rating(int _rating) {
		this._rating = _rating;
	}
	
	
	// SERIALISATION DE LA CLASSE
	// --------------------------
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public void writeToParcel(Parcel dest, int flags) {

		dest.writeInt(get_id());
		dest.writeString(get_titre());
		dest.writeString(get_filename());
		dest.writeString(get_album());
		dest.writeString(get_artiste());
		dest.writeInt(get_duree());
		dest.writeInt(get_rating());
		
	}
	
	public static final Parcelable.Creator<Music> CREATOR = new Parcelable.Creator<Music>()
	{
	    @Override
	    public Music createFromParcel(Parcel source)
	    {
	        return new Music(source);
	    }
	 
	    @Override
	    public Music[] newArray(int size)
	    {
	    	return new Music[size];
	    }
	};
	
	public Music(Parcel in) {
		this.set_id(in.readInt());
		this.set_titre(in.readString());
		this.set_filename(in.readString());
		this.set_album(in.readString());
		this.set_artiste(in.readString());
		this.set_duree(in.readInt());
		this.set_rating(in.readInt());
		
	}
}
